<?php

namespace app\storecheck\controller;

use app\common\controller\PCBase;
use app\BaseController;//测试专用
use app\storecheck\logic\WarehouseEntryLogic;
use think\facade\Db;
use Throwable;
use app\common\library\Upload;

class WarehouseEntry extends PCBase
{


    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * index
     * @throws Throwable
     */
    public function index()
    {
        $params     = $this->request->post();
        return (new WarehouseEntryLogic())->index($params);
    }

    
    /**
     * 添加
     * @throws Throwable
     */
    public function add()
    {
        $post = $this->request->post();
        $WarehouseEntrylogLogic = new WarehouseEntryLogic();
        $result = $WarehouseEntrylogLogic->add($post);
        return $result;
    }

    /**
     * 回显
     * @throws Throwable
     */
    public function find($id = null)
    {
        $post = $this->request->post();
        $id = $post['id'] ?? 0;
        $WarehouseEntrylogLogic = new WarehouseEntryLogic();
        $result = $WarehouseEntrylogLogic->find($id);
        return $result;
    }
    /**
     * 编辑
     * @throws Throwable
     */
    public function edit()
    {
        $post = $this->request->post();
        $WarehouseEntrylogLogic = new WarehouseEntryLogic();
        $result = $WarehouseEntrylogLogic->edit($post);
        return $result;
    }
    /**
     * export
     * @throws Throwable
     */
    public function export()
    {
        $post = $this->request->post();
        $WarehouseEntrylogLogic = new WarehouseEntryLogic();
        $result = $WarehouseEntrylogLogic->export($post);
        return $result;
    }
    
    

    /**
     * @desc   导入数据处理
     * @author luckyXiong
     * @date   2025-01-24
     */
    public function importInfo(){
        $file       = $this->request->file('file');
        $res        = (new Upload($file))->upload(null, $this->getAdminId()); 
        $WarehouseEntryLogic = new WarehouseEntryLogic();
        return $WarehouseEntryLogic->importInfo($res['url']);
    }

}
